package com.xayy.health.mgt.mapper;

import com.xayy.health.core.config.datasource.DatasourceSelector;
import com.xayy.health.mgt.model.TelemetryData;
import com.xayy.health.mgt.model.dto.TelemetryDto;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *数据源选择
 * @author Administrator
 */
public interface SelectTelemetryDataSourceMapper {

    /**
     * 创建遥测数据表
     *
     * @param tableName 表名
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void createTaskTable(@Param("tableName")String tableName);


    /**
     * 根据任务id获取遥测数据
     * @param tableName 表名
     * @param taskId 任务id
     * @return List<TelemetryData>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TelemetryData> getTelemetryListByTaskId(@Param("tableName")String tableName,@Param("taskId")Long taskId );


    /**
     * 插入遥测数据
     * @param tableName 表名
     * @param list 遥测数据
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void insertTelemetryListData(@Param("tableName")String tableName,@Param("list")List<TelemetryData> list );


    /**
     * 删除遥测数据
     * @param tableName 表名
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void deleteTelemetryData(@Param("tableName")String tableName);


    /**
     * 删除表
     * @param tableName 表名
     */
    @DatasourceSelector(sourceName = "clickhouse")
    void deleteTable(@Param("tableName")String tableName);

    /**
     * 获取遥测数据
     * @param tableName 表名称
     * @param telemetryDto 查询条件
     * @return List<TelemetryData>
     */
    @DatasourceSelector(sourceName = "clickhouse")
    List<TelemetryData> selectTelemetryListData(@Param("tableName") String tableName, @Param("telemetryDto")TelemetryDto telemetryDto);
}
